package com.ywk.base.concurrency.thread.createWay;

import lombok.SneakyThrows;

/**
 * 线程创建方式2:继承Thread类
 * @Author zbh
 * @Date 2024/1/2
 */
public class RunnableTest implements Runnable{

    public static void main(String[] args) {
        /*RunnableTest r = new RunnableTest();
        r.run();//这是方法的正常调用，没有创建新的线程*/
        new Thread(new RunnableTest()).start();
        System.out.println("当前线程："+Thread.currentThread().getName()+"-M");
    }

    @SneakyThrows
    @Override
    public void run() {
        System.out.println("当前线程："+Thread.currentThread().getName()+"-R");
        Thread.sleep(3000);
        System.out.println("R1");
    }
}
